<?php

/**
 * Export all member records in .xls format
 * with the help of the xlsHelper
 * @author Omar Elshal
 */
//input the export file name
$this->xls->setHeader('ArchivedTweets_' . date('Y_m_d'));

$this->xls->addXmlHeader();
$this->xls->setWorkSheetName('ArchivedTweets');

//1st row for columns name
$this->xls->openRow();
$this->xls->writeString('Tweet ID');
$this->xls->writeString('Tweet');
$this->xls->writeString('Time');
$this->xls->writeString('Retweets');
$this->xls->writeString('Favourites');
$this->xls->writeString('User');
$this->xls->writeString('Account');
$this->xls->closeRow();

//rows for data

foreach ($models as $model):
    $this->xls->openRow();
    $this->xls->writeNumber($model['posts']['postID']);
    $this->xls->writeString($model['posts']['text']);
    $this->xls->writeString($model['posts']['time']);
    $this->xls->writeNumber($model['tweets']['retweets']);
    $this->xls->writeNumber($model['tweets']['favourites']);
    $this->xls->writeString($model['users']['username']);
    $this->xls->writeString($model['accounts']['name']);

    $this->xls->closeRow();
endforeach;

$this->xls->addXmlFooter();
exit();
?> 